package com.uniflow.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDateTime;

/**
 * 角色权限关联实体类
 * 
 * @author luban
 * @since 1.0.0
 */
@ApiModel(description = "角色权限关联")
@TableName("role_permissions")
public class RolePermission {
    
    @ApiModelProperty("关联ID")
    private String id;
    
    @ApiModelProperty("角色ID")
    private String roleId;
    
    @ApiModelProperty("权限ID")
    private String permissionId;
    
    @ApiModelProperty("是否授权：1-授权，0-拒绝")
    private Boolean granted;
    
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    
    @ApiModelProperty("创建人ID")
    private String createdBy;
    
    @ApiModelProperty("创建人姓名")
    private String createdByName;
    
    // 关联查询字段
    @ApiModelProperty("角色信息")
    private Role role;
    
    @ApiModelProperty("权限信息")
    private Permission permission;
    
    @ApiModelProperty("创建人信息")
    private User creator;
    
    // 构造函数
    public RolePermission() {}
    
    public RolePermission(String roleId, String permissionId) {
        this.roleId = roleId;
        this.permissionId = permissionId;
        this.granted = true;
        this.createdAt = LocalDateTime.now();
    }
    
    public RolePermission(String roleId, String permissionId, Boolean granted) {
        this.roleId = roleId;
        this.permissionId = permissionId;
        this.granted = granted;
        this.createdAt = LocalDateTime.now();
    }
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getRoleId() {
        return roleId;
    }
    
    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }
    
    public String getPermissionId() {
        return permissionId;
    }
    
    public void setPermissionId(String permissionId) {
        this.permissionId = permissionId;
    }
    
    public Boolean getGranted() {
        return granted;
    }
    
    public void setGranted(Boolean granted) {
        this.granted = granted;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public String getCreatedBy() {
        return createdBy;
    }
    
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }
    
    public String getCreatedByName() {
        return createdByName;
    }
    
    public void setCreatedByName(String createdByName) {
        this.createdByName = createdByName;
    }
    
    public Role getRole() {
        return role;
    }
    
    public void setRole(Role role) {
        this.role = role;
    }
    
    public Permission getPermission() {
        return permission;
    }
    
    public void setPermission(Permission permission) {
        this.permission = permission;
    }
    
    public User getCreator() {
        return creator;
    }
    
    public void setCreator(User creator) {
        this.creator = creator;
    }
    
    @Override
    public String toString() {
        return "RolePermission{" +
                "id='" + id + '\'' +
                ", roleId='" + roleId + '\'' +
                ", permissionId='" + permissionId + '\'' +
                ", granted=" + granted +
                ", createdAt=" + createdAt +
                '}';
    }
}